﻿// JScript 文件

// 给标签中插入内容
function selectcolumuname(tag)
{   
        var myField; 
        myField = document.getElementById('txtContent'); 
        if (document.selection) { 
                myField.focus(); 
                sel = document.selection.createRange(); 
                sel.text = tag; 
                myField.focus(); 
        } 
        else if (myField.selectionStart || myField.selectionStart == '0') { 
                var startPos = myField.selectionStart; 
                var endPos = myField.selectionEnd; 
                var cursorPos = endPos; 
                myField.value = myField.value.substring(0, startPos) 
                                          + tag 
                                          + myField.value.substring(endPos, myField.value.length); 
                cursorPos += tag.length; 
                myField.focus(); 
                myField.selectionStart = cursorPos; 
                myField.selectionEnd = cursorPos; 
        } 
        else { 
                myField.value += tag; 
                myField.focus(); 
        } 
}

//模板调用
function insertColum(tag)
{  
        var strTag="{"+tag+"}" 
        var myField; 
        myField = document.getElementById('txtContent'); 
        if (document.selection) { 
                myField.focus(); 
                sel = document.selection.createRange(); 
                sel.text = strTag; 
                myField.focus(); 
        } 
        else if (myField.selectionStart || myField.selectionStart == '0') { 
                var startPos = myField.selectionStart; 
                var endPos = myField.selectionEnd; 
                var cursorPos = endPos; 
                myField.value = myField.value.substring(0, startPos) 
                                          + strTag 
                                          + myField.value.substring(endPos, myField.value.length); 
                cursorPos += tag.length; 
                myField.focus(); 
                myField.selectionStart = cursorPos; 
                myField.selectionEnd = cursorPos; 
        } 
        else { 
                myField.value += strTag; 
                myField.focus(); 
        } 
}


var flag=false;
function DrawImage(ImgD){
    var image=new Image();
    image.src=ImgD.src;
    if(image.width>0 && image.height>0){
        flag=true;
        if(image.width/image.height>= 200/200){
            if(image.width>200){
                ImgD.width=200;
                ImgD.height=(image.height*200)/image.width;
            }else{
                ImgD.width=image.width;
                ImgD.height=image.height;
            }
            ImgD.alt=image.width+"×"+image.height;
        }else{
            if(image.height>200){
                ImgD.height=200;
                ImgD.width=(image.width*200)/image.height;
            }else{
                ImgD.width=image.width;
                ImgD.height=image.height;
            }
            ImgD.alt=image.width+"×"+image.height;
        }
    }
}